//
//  GroupSetUpHeaderCell.m
//  PigMarket
//
//  Created by mac on 2019/6/19.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "GroupSetUpHeaderCell.h"

@interface GroupSetUpHeaderCell ()

/**
 img
 */
@property (nonatomic , strong) UIImageView *headerImg;
/**
 name
 */
@property (nonatomic , strong) UILabel *nameLab;
@end
@implementation GroupSetUpHeaderCell
#pragma mark - init method
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    // 添加子控件
    [self.contentView addSubview:self.headerImg];
    [self.contentView addSubview:self.nameLab];
}

- (void)initLayout {
    // 布局子控件
    [self.headerImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.contentView.mas_centerX);
        make.top.mas_equalTo(10);
        make.size.mas_equalTo(CGSizeMake(50, 50));
    }];
    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.contentView.mas_centerX);
        make.top.mas_equalTo(self.headerImg.mas_bottom).offset(4);
        make.size.mas_equalTo(CGSizeMake(50, 16));
    }];
}
- (void)configCellWithModel:(TGroupMemberCellData *)model{
    
    self.nameLab.text = model.name;
//    if ([model.head isEqualToString:@"chat_group_addmember"] || [model.head isEqualToString:@"chat_group_deletemember"]) {
//        self.headerImg.image = model.avatar;
//
//    } else {
    self.headerImg.image = model.avatar;

//    }
}
#pragma mark - getter and setter
- (UIImageView *)headerImg {
    if (!_headerImg) {
        _headerImg = [[UIImageView alloc] init];
        _headerImg.layer.cornerRadius = 25;
        _headerImg.layer.masksToBounds = YES;
        _headerImg.userInteractionEnabled = YES;
        self.headerImg.backgroundColor = [UIColor greenColor];
    }
    return _headerImg;
}
- (UILabel *)nameLab {
    if (!_nameLab) {
        _nameLab = [[UILabel alloc] init];
        _nameLab.textColor = [UIColor colorWithHexString:@"#333333"];
        _nameLab.font = [UIFont systemFontOfSize:11];
        _nameLab.textAlignment = NSTextAlignmentCenter;
    }
    return _nameLab;
}
@end

